<template>
	<div>
		<div>
			<a-tag
				v-for="item in roles"
				:key="item.id"
				:color="getColor(item.status)"
				@click="toDetail(flowId,item)"
				@change="change"
			>
				{{ item.name }}
			</a-tag>
		</div>
	</div>
</template>
<script setup lang="ts">
/**
 * 项目审核角色状态按钮
 */
import { ref, watch, onMounted, getCurrentInstance, reactive } from "vue";
import { post } from "../utils";
import router from "../router";
const { proxy } = getCurrentInstance();
const getColor = (status) => {
	var color = {
		"-1": "orange",
		"0": "red",
		"1": "green",
	};

	return color[status + ""] || "";
};
const props = defineProps({
	roles: {
		type: Object,
		required: false,
		default: null,
	},
	// 审批项id
	flowId: {
		type: Number,
		required: false,
		default: 0,
	},
	// 模块标识
	moduleId: {
		type: String,
		required: false,
		default: "",
	},
	// 模块下内容id
	itemId: {
		type: Number,
		required: false,
		default: 0,
	},
});

//定义emit
const emit = defineEmits([
	"update:flowId",
	"update:moduleId",
	"update:itemId",
	"update:roles",
	"change",
]);
// const depts = ref();
onMounted(async () => {
	// depts.value = props.roles;
	if (props.flowId !== 0) {
		// run({ id: props.flowId });
	} else if (props.moduleId !== "" && props.itemId !== 0) {
		// run({ moduleId: props.moduleId, itemId: props.itemId });
	}
});
const change = (e) => {
	emit("change", e);
};
const toDetail = (rowid, item) => {
	var data = { act: "click", data: { id: rowid, item: item } };
	emit("change", data);
	// router.push({
	// 	name: "flowDetail",
	// 	query: {
	// 		itemId: props.itemId,
	// 		moduleId: props.moduleId,
	// 		id: rowid,
	// 	},
	// });
};
// run();
</script>